<template>
  <div class="main1">
    <div class="formData">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="字段">
          <el-input v-model="formInline.user" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="main">
      <el-button type="primary" class="btnAdd" @click="handEdit">新增</el-button>
      <el-button type="primary" class="btnAdd1" @click="synchronize" :disabled="disBtn">同步</el-button>
      <el-table border :data="tableData" style="width: 100%">
        <el-table-column width="50" label="序号" type="index"></el-table-column>
        <el-table-column prop="date" label="名称"></el-table-column>
        <el-table-column prop="name" label="脚本"></el-table-column>
        <el-table-column prop="address" label="创建人"></el-table-column>
        <el-table-column prop="address" label="操作">
          <el-link type="primary" plain @click="handEdit">编辑</el-link>
          <el-link type="primary" plain @click="handEdit">删除</el-link>
          <el-link type="primary" plain @click="handleshow">脚本</el-link>
          <el-link type="primary" plain @click="handEdit">测试</el-link>
        </el-table-column>
      </el-table>
    </div>
    <dialogEngin v-if="dialogVisible" :dialogVisible="dialogVisible" @close="close"></dialogEngin>
    <el-dialog left title="脚本" :visible.sync="showData1" :before-close="dialogClose1">
      <el-form :model="fromData" label-width="100px">
        <el-form-item label="脚本">
          <el-input type="textarea" width="100%" v-model="fromData.dataSetSql" :rows="25"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import dialogEngin from "./component/dialogEngin";
export default {
  name: "dataSource.vue",
  components: { dialogEngin },
  data() {
    return {
      showData1:false,
      disBtn: false,
      formInline: {
        user: "",
        region: "",
      },
      dialogVisible: false,
      tableData: [
        {
          date: "任务延期率",
          name: "select14",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "代码重复率",
          name: "select15",
          address: "韩xx",
        },
        {
          date: "债务",
          name: "select16",
          address: "何xx",
        },
        {
          date: "债务率",
          name: "select17",
          address: "刘xx",
        },
      ],
      fromData:{
        dataSetSql:''//脚本
      }
    };
  },
  methods: {
    onSubmit(){},
    handEdit() {
      this.dialogVisible = true;
    },
    close() {
      this.dialogVisible = false;
    },
    handleshow(obj){
      this.showData1=true
      this.fromData.dataSetSql=obj.dataSetSql
    },
    synchronize() {
      this.disBtn = true;
      // query().then((res) => {
      //   if (res && res.date === 200) {
      //     this.$message.success(res.date);
      //   } else {
      //     this.disBtn = false;
      //   }
      // });
    },
    dialogClose1(){
      this.showData1=false
      this.fromData.dataSetSql=''
    }

  },
};
</script>

<style lang="scss" scoped>
.main1 {
  margin: 20px;
  .main {
    position: relative;
    .btnAdd {
      position: absolute;
      right: 20px;
      top: -45px;
    }
    .btnAdd1 {
      position: absolute;
      right: 100px;
      top: -45px;
    }
  }

  .el-link {
    margin-left: 10px;
  }
}
</style>
